package com.megvii.koala.data.bean;

import com.megvii.koala.constance.SubjectType;

import java.io.Serializable;
import java.util.ArrayList;

public class VisitorBean extends CreatureBean implements Serializable
{
    private static final long serialVersionUID = 4933299049724623803L;

    public static final String ID_HISTORY = "ID_HISTORY";

    public static final String ID_NOPHOTO = "ID_NOPHOTO";

    public static VisitorBean fromCreatureBean(CreatureBean creature)
    {
        //TODO 写个反射copy变量的工具
        VisitorBean visitor = new VisitorBean();
        visitor.id = creature.id;
        visitor.avatar = creature.avatar;
        visitor.subject_type = creature.subject_type;
        visitor.name = creature.name;
        visitor.start_time = creature.start_time;
        visitor.end_time = creature.end_time;
        visitor.visit_notify = creature.visit_notify;
        visitor.purpose = creature.purpose;
        visitor.remark = creature.remark;
        visitor.description = creature.description;
        visitor.department = creature.department;
        visitor.phone = creature.phone;
        visitor.nameFirst = creature.nameFirst;
        visitor.pingyinName = creature.pingyinName;
        visitor.zimuName = creature.zimuName;
        visitor.come_from = creature.come_from;
        if (creature.photos == null)
        {
            visitor.photos = null;
        }
        else
        {
            visitor.photos = new ArrayList<>();
            for (UpPictureBean pictureBean : creature.photos)
            {
                UpPictureBean clonedPictureBean = (UpPictureBean) pictureBean.clone();
                visitor.photos.add(clonedPictureBean);
            }
        }
        return visitor;
    }

    public boolean isVip()
    {
        return subject_type == SubjectType.VISITOR_VIP;
    }

    public void setVip(boolean vip)
    {
        subject_type = vip ? SubjectType.VISITOR_VIP : SubjectType.VISITOR;
    }
}